<?php /*
	EZ-Shop, Starter E-Commerce Platform
    Copyright (C) 2009  David Hinchliffe - FC Software Ltd

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/ ?>
<table border="0" cellpadding="0" cellspacing="0" width="165px;">
<tr>
<td>
<div class="leftmenu">
<div class="leftcatheading"><strong>Categories</strong></div>
<ul>
 <?php
	  	$sql="SELECT tblprodcategory.*, tblprodcategorydesc.* FROM `tblprodcategory` INNER JOIN `tblprodcategorydesc` ON tblprodcategory.intcategoryid = tblprodcategorydesc.intcatid  where tblprodcategory.intparentid=0 ORDER BY `intsortorder` ASC";
		$res=$n02586916_db->select($sql);
		if(count($res)>0) {	
			for($i=0;$i<count($res);$i++) {
				$cat_id= $res[$i]['intcategoryid'];
				$sql5="select * from tblproducts where intcategoryid='$cat_id' and intstatus=0";
				$resc=$n02586916_db->select($sql5);
?>	
	<li><a class="hide" href="category.php?intcatid=<?php echo $cat_id;?>"><?php echo stripslashes($res[$i]['varcategoryname']);?></a></a>
		<?php
				//select subcats for primary cat
				$subsql = "SELECT tblprodcategory.*, tblprodcategorydesc.* FROM `tblprodcategory` INNER JOIN `tblprodcategorydesc` ON tblprodcategory.intcategoryid = tblprodcategorydesc.intcatid  where tblprodcategory.intparentid=$cat_id ORDER BY `intsortorder` ASC";
				$subresults=$n02586916_db->select($subsql);
				if(count($subresults)>0) {
				echo "<ul>";
					for($q=0;$q<count($subresults);$q++) {
						$sql5="select * from tblproducts where intcategoryid=".$subresults[$q]['intcategoryid']." and intstatus=0";
						$cres=$n02586916_db->select($sql5);
		?>		
						<li><a href="category.php?intcatid=<?php echo $subresults[$q]['intcategoryid'];?>" title="<?php echo stripslashes($subresults[$q]['varcategoryname']);?>"><?php echo stripslashes($subresults[$q]['varcategoryname']);?></a></li>
<?php
					}
				echo "</ul></li>";
				}
			}
		}?>
</ul>
</div>
</td></tr>
<tr><td>
<?php 
 	$sql="select * from tblideas where inttype=1 and intstatus=0";
	$res=$n02586916_db->select($sql);
	if(count($res)>0) {		
	  ?>
	  <div class="leftcatheading"><strong><a class="giftoffer" href="specialoffer.php?view=on">On Special Offer (<?php echo count($res);?>)</a></strong></div>
   <?php }
	$sql="select * from tblideas where inttype=2 and intstatus=0";
	$res=$n02586916_db->select($sql);
	if(count($res)>0) {	
	  ?>
	  <div class="leftcatheading"><strong><a class="giftoffer" href="specialoffer.php?view=giftidea">Gift Ideas (<?php echo count($res);?>)</a></strong></div>
<?php }?>
</td></tr>

<tr><td>
<div class="leftcatheading"><strong>Brands</strong></div>
<?php
	   $sql="select * from tblmanufactures";
	   $resmanu=$n02586916_db->select($sql);
	   if(count($resmanu)>0) {
	   	for($m=0;$m<count($resmanu);$m++) {
		$manfid=$resmanu[$m]['intmanufactureid'];
		$sql0="select * from tblproducts where intmanufacture='$manfid' and intstatus='0'";
		$resc=$n02586916_db->select($sql0);
	  ?>
       <table cellpadding="0" cellspacing="0" height="10">
     <tr>
          <td>&nbsp;&nbsp;<a class="menulink" href="category.php?manufid=<?php echo $resmanu[$m]['intmanufactureid'];?>"><?php echo $resmanu[$m]['varname'];?>(<?php echo count($resc);?>)</a></td>
        </tr>
	  </table><?php }}?>
</td></tr>

</table>



		